const itemModel = require('../models/items.model')
class ItemService {
  items = itemModel
  findAll () {
    return this.items.find({ deleted: false })
  }
  addOne (data) {
    return this.items.create(data)
  }
  findOne (id) {
    return this.items.find({ deleted: false, _id: id })
  }
  updateOne (id, data) {
    return this.items.findOneAndUpdate({ _id: id }, data)
  }
  deleteOne (id) {
    return this.items.findOneAndRemove({ _id: id })
  }
}

module.exports = ItemService